'''
爬取去哪儿了_机票列表(注意:这是一个H5页面)
网址：https://m.flight.qunar.com/ncs/page/flightlist?_firstScreen=1&_gogokid=12&arrCity=%E4%B8%8A%E6%B5%B7&baby=0&cabinType=0&child=0&depCity=%E5%8C%97%E4%BA%AC&from=touch_index_search&goDate=2024-10-17

需要处理 headers 中的请求参数
        请求参数中的__m__

加密用到了：SHA1 加密算法 和 MD5 加密算法 及 这两者的混合加密；

SHA1在线加密工具 https://www.iamwawa.cn/jiami.html
md5在线加密工具 https://www.sojson.com/md5
'''

import requests

cookies = {
    'QN1': '00014700306c659bace03534',
    'QN300': 's%3Dbaidu',
    'QN99': '1219',
    'QN48': '0000f2802f10659bb0706e0e',
    'ctt_june': '1683616182042##iK3wVRv%3DVuPwawPwasv%2BVRtsXK2mXKDAVPP%2BEDWDEDkTVKjOVPXAWDjwaSGhiK3siK3saKgwWstAaSPAVR38aUPwaUvt',
    'Alina': 'a852929a-d18657-91427441-57816062-508e66fcf010',
    'QN601': '951b6f39b2b8be4a2cbe8a047112da5f',
    'quinn': 'd52bec9a7cb2cf1ab456022fae94870690c9bafea9dde246fec2d2db642d69e4722e15b42401e47f1a85111e1f7ad33b',
    '_i': 'VInJOmJqqqwCCLA3MgAkKQPfRc2q',
    '_vi': 'bWpmn8gL5bYs8Xopf0cKJsP6tnXSHtVPC1utCM9ratn168AUeJtJgo0TffFD3uMFV5IL9E1VlztjNe1yyfsj7Cr_SqLOhVQyws2WqIFwp2zIHrdg7KWu4YRQb1eh2iiAr1yMuWW2rM1XPxYSI8byLFM-NAepO05b0nXQR6Fkm-ns',
    'QN25': '6493c47c-3fcb-4f18-8bf8-dbe089dbc31d-9f992f90',
    'QN621': 'fr%3Dtouch_index_search',
    'F235': '1727924845398',
    'QN668': '51%2C57%2C52%2C57%2C59%2C54%2C55%2C53%2C52%2C51%2C52%2C55%2C56',
    'cs_june': '50940505a0f60fc6e73720ae0ad6bfd1d2d1d1e08868bb8b7d54a9eb24685b0c7d91ef27268202f27edf2afcf2ac31138f0f14e4213a1b4c029ae23cffe86012b17c80df7eee7c02a9c1a6a5b97c1179ccf033fb2721b179ec7ae3270c311b095a737ae180251ef5be23400b098dd8ca',
    'ctf_june': '1683616182042##iK3wVKaNVuPwawPwa%3DXNa2X%2BXKHGEDa%3DXSTGESgmERvmWsjwW2P%2BaSHDWSgNiK3siK3saKgwWs2%3DWKawasjNWuPwaUvt',
}

headers = {
    'accept': 'application/json, text/javascript',
    'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
    # 'cce842': '3f49a1ff4020d33cd028d79ddb4c4171', # 加密处理
    '96010b': "cf593ec056b0c87b6fe218223f20cee1a5b3a697",
    'content-type': 'application/json',
    # 'cookie': 'QN1=00014700306c659bace03534; QN300=s%3Dbaidu; QN99=1219; QN48=0000f2802f10659bb0706e0e; ctt_june=1683616182042##iK3wVRv%3DVuPwawPwasv%2BVRtsXK2mXKDAVPP%2BEDWDEDkTVKjOVPXAWDjwaSGhiK3siK3saKgwWstAaSPAVR38aUPwaUvt; Alina=a852929a-d18657-91427441-57816062-508e66fcf010; QN601=951b6f39b2b8be4a2cbe8a047112da5f; quinn=d52bec9a7cb2cf1ab456022fae94870690c9bafea9dde246fec2d2db642d69e4722e15b42401e47f1a85111e1f7ad33b; _i=VInJOmJqqqwCCLA3MgAkKQPfRc2q; _vi=bWpmn8gL5bYs8Xopf0cKJsP6tnXSHtVPC1utCM9ratn168AUeJtJgo0TffFD3uMFV5IL9E1VlztjNe1yyfsj7Cr_SqLOhVQyws2WqIFwp2zIHrdg7KWu4YRQb1eh2iiAr1yMuWW2rM1XPxYSI8byLFM-NAepO05b0nXQR6Fkm-ns; QN25=6493c47c-3fcb-4f18-8bf8-dbe089dbc31d-9f992f90; QN621=fr%3Dtouch_index_search; F235=1727924845398; QN668=51%2C57%2C52%2C57%2C59%2C54%2C55%2C53%2C52%2C51%2C52%2C55%2C56; cs_june=50940505a0f60fc6e73720ae0ad6bfd1d2d1d1e08868bb8b7d54a9eb24685b0c7d91ef27268202f27edf2afcf2ac31138f0f14e4213a1b4c029ae23cffe86012b17c80df7eee7c02a9c1a6a5b97c1179ccf033fb2721b179ec7ae3270c311b095a737ae180251ef5be23400b098dd8ca; ctf_june=1683616182042##iK3wVKaNVuPwawPwa%3DXNa2X%2BXKHGEDa%3DXSTGESgmERvmWsjwW2P%2BaSHDWSgNiK3siK3saKgwWs2%3DWKawasjNWuPwaUvt',
    'csht': '',
    'origin': 'https://m.flight.qunar.com',
    'pre': '5e9ff1b4-776041-65441684-57be6098-d27b9d722993',
    'priority': 'u=1, i',
    'referer': 'https://m.flight.qunar.com/ncs/page/flightlist?_firstScreen=1&_gogokid=12&arrCity=%E4%B8%8A%E6%B5%B7&baby=0&cabinType=0&child=0&depCity=%E5%8C%97%E4%BA%AC&from=touch_index_search&goDate=2024-10-17',
    'sec-ch-ua': '"Microsoft Edge";v="129", "Not=A?Brand";v="8", "Chromium";v="129"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-origin',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0',
    'wps': '21',
    'x-requested-with': 'XMLHttpRequest',
}

json_data = {
    '_firstScreen': '1',
    '_gogokid': '12',
    'arrCity': '上海',
    'baby': '0',
    'cabinType': '0',
    'child': '0',
    'depCity': '北京',
    'from': 'touch_index_search',
    'goDate': '2024-10-17',
    'firstRequest': True,
    'Bella': '1683616182042##55b444f152b96c5a29e0e4cd2cb3336f941e9e03##iKohiK3wgMkMf-i0gUPwaUPsXuPwaUPwaUPwXwPwa5TQjOWxcI10aS30a=D0aS3wWsXwiK3siK3sWDDOWDj+W=khESThEKTIWwPwawPwasD+aSgNWRPsaSamaRa0aS30a2a0aSisyI0wcIkNiK3wiKWTiK3wWKv=WR0HjKTUjKP8WID8fMDNaMfSWSkUWsPnaS2sjOj0aS30a2a0aSi=y-ELfuPwaUPsXuPwaUkGWuPmEukhXUkGWuPNawkTXukGWuPmWhkhEUkGWwkhEhPNaukGWUPNXwkhXukGWwkTWukTVhkGWUPNXwPmEhkGWuPmXukTauPwaUPwXwPwaMe0d-oxgMEsiK3wiKWTiK3wiKiRiPPAiKHGiPihiPPNiKtwiPDsiPPAiKt=iPiIiKiRiPPmiKtmiPGTiPP+iKHIiPGDiPPOiK0IiPDAiPPmiPGIiPDwiKiRiK3wiKiRiK3wfIksj+iQgCEQcOm0aS30a=D0aS30EKP0VDP0X230EKP0VKa0XPD0EKP0VRX0X2jpP-kbj-3bjOFeJukGVukTawPNEukGWUPNXwkhXukGWwkTWukTVhPwXwkGWwPmVukhVukGWhkhXUkhWwPwaUPwXwPwaMHxg+X0aS30a=D0aSieqMfLy9opohNno9NHgUNScO=0aS30a2a0aSisj+iQgCEKgMa0aS30a=D0WP30aSiScOAecOmbg-kbj-irdUNSiK3wiKiRiK3wg90ef+abg-kbj-irdUNScwPwaUPAEhP+Ehvt##cGb9J56A6AM499X_zu-42##_firstScreen,_gogokid,arrCity,baby,cabinType,child,depCity,from,goDate,firstRequest',
    'startNum': 0,
    'sort': 5,
    'r': 1727945323800,
    '_v': 2,
    'underageOption': '',
    'st': 1727945323798,
    # '__m__': '3881c16c3d41514fc775e0f61548d088', # 加密处理
    '__m__': '1b3f26086cde018285e7cce07b7aa9a5',
}

response = requests.post('https://m.flight.qunar.com/flight/api/touchInnerList', cookies=cookies, headers=headers, json=json_data)

print(response.json())
with open('case1.json', 'w', encoding='utf-8') as fp:
    fp.write(str(response.json()))

